/**
  ETFRoot project, Anyang Normal University && IMP-CAS
  \class ETFDCHit
  \brief for a DC hit, i.e. a fired sense wire.
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2021-10-28
  \date 2021-11-30 last modified
  \attention
  changelog
  <table>
  <tr>  <th>Date         <th>Author      <th>Description                   </tr>
  <tr>  <td>2021-10-28   <td>Asia Sun    <td>file created                  </tr>
  </table>

  \copyright Copyright (c) 2021 Anyang Normal U. && IMP-CAS with LGPLv3 LICENSE
*/

#ifndef ETFDCHit_h
#define ETFDCHit_h

#include "ETFHit.h"

class ETFHPTDCChannel;

class ETFDCHit : public ETFHit{
public:
  ETFDCHit();
  ETFDCHit(const ETFDCHit &t); ///< copy ctor
  ETFDCHit &operator=(const ETFDCHit &t); ///< assignment ctor
  virtual ~ETFDCHit();

  virtual void Initialize();
  virtual void SetDataChannel(const ETFHPTDCChannel *ch);
  bool SetDriftTimeStart(double time0); ///< \retval: true if drift time is new
  void SetR(double r){ fR = r; }
  void SetDriftDistance(double r){ SetR(r); }
  void SetChi(double chi){ fChi = chi; }
  void SetFittingResidue(double chi){ SetChi(chi); }
  void SetLayerId(int id){ fLayerId = id; }
  void SetNu(int nu){ fWireId = nu; } ///< wire id in the sense wire layer
  void SetWireId(int id){ SetNu(id); } ///< wire id in the sense wire layer
  void SetProjection(const double *p); ///< set fProj

  double GetDriftTime() const{ return fT; }
  double GetT() const{ return fT; }
  double GetDriftDistance() const{ return fR; }
  double GetR() const{ return fR; }
  double GetProjZ() const; ///< \retval fProj[2]
  double GetProjX() const; ///< \retval fProj[0]
  void GetProjZX(double &z, double &x) const; ///< \retval fProj[0] and fProj[2]
  void GetProjZXR(double &z, double &x, double &r) const;
  double GetChi() const{ return fChi; }
  int GetLayerId() const{ return fLayerId; }
  int GetNu() const{ return fWireId; }
  int GetWireId() const{ return fWireId; }
  const ETFHPTDCChannel *GetDataChannel() const;
  virtual void Print(); ///< print the hit info
  virtual void ConfigureDraw(); ///< configure fGHit

  ClassDef(ETFDCHit, 1); // ABC for an ETF hit

protected:
  double fT, fR, fChi; ///< drift time, drift distance and fitting residue
  const ETFHPTDCChannel *fCh; //-> ///< the original data channel
  int fLayerId; ///< id of sense wire layer the hit is in, in the context of the DC array
  int fWireId; ///< layer-local id of the sense wire that the hit belongs to
  double fProj[3]; ///< projection of fPos[3] to the normal plane (zOx) of the sense wire
};

#endif
